%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for subscriptions/basics/forum-messages"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 8, 16, 17, 45, 7, 18<br />2: Listen[9]"):::bucket
    Bucket1("Bucket 1 (subscription)<br />Deps: 18, 4<br /><br />ROOT __Item{1}ᐸ9ᐳ[10]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 11, 18<br /><br />ROOT JSONParse{1}ᐸ10ᐳ[11]<br />1: <br />ᐳ: Access[12], Access[14], Lambda[13]<br />2: PgSelect[15]<br />3: PgSelectRows[20]<br />ᐳ: First[19], PgSelectSingle[21]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 21, 18<br /><br />ROOT PgSelectSingle{2}ᐸmessagesᐳ[21]<br />1: <br />ᐳ: 22, 23, 24, 25, 26, 34<br />2: PgSelect[27], PgSelect[35]<br />3: PgSelectRows[32], PgSelectRows[38]<br />ᐳ: 31, 33, 37, 39"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 33, 26<br /><br />ROOT PgSelectSingle{3}ᐸforumsᐳ[33]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 39<br /><br />ROOT PgSelectSingle{3}ᐸusersᐳ[39]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4 & Bucket5

    %% plan dependencies
    Listen9[["Listen[9∈0@s] ➊"]]:::plan
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSubscriberᐳ"}}:::plan
    Lambda7{{"Lambda[7∈0] ➊<br />More deps:<br />- Constantᐸ'ca700000-0000-0000-0000-000000000ca7'ᐳ[45]"}}:::plan
    Access8 & Lambda7 --> Listen9
    Object18{{"Object[18∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 3"}}:::plan
    Access16{{"Access[16∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access17{{"Access[17∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access16 & Access17 --> Object18
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access16
    __Value2 --> Access17
    __Item10[/"__Item[10∈1]<br />ᐸ9ᐳ"\]:::itemplan
    Listen9 ==> __Item10
    JSONParse11[["JSONParse[11∈1]<br />ᐸ10ᐳ"]]:::plan
    __Item10 --> JSONParse11
    PgSelect15[["PgSelect[15∈2]<br />ᐸmessagesᐳ<br />More deps:<br />- Object[18]"]]:::plan
    Access14{{"Access[14∈2]<br />ᐸ11.idᐳ"}}:::plan
    Access14 --> PgSelect15
    Access12{{"Access[12∈2]<br />ᐸ11.opᐳ"}}:::plan
    JSONParse11 --> Access12
    Lambda13{{"Lambda[13∈2]"}}:::plan
    Access12 --> Lambda13
    JSONParse11 --> Access14
    First19{{"First[19∈2]"}}:::plan
    PgSelectRows20[["PgSelectRows[20∈2]"]]:::plan
    PgSelectRows20 --> First19
    PgSelect15 --> PgSelectRows20
    PgSelectSingle21{{"PgSelectSingle[21∈2]<br />ᐸmessagesᐳ"}}:::plan
    First19 --> PgSelectSingle21
    PgSelect27[["PgSelect[27∈3]<br />ᐸforumsᐳ<br />More deps:<br />- Object[18]"]]:::plan
    PgClassExpression26{{"PgClassExpression[26∈3]<br />ᐸ__messages__.”forum_id”ᐳ"}}:::plan
    PgClassExpression26 --> PgSelect27
    PgSelect35[["PgSelect[35∈3]<br />ᐸusersᐳ<br />More deps:<br />- Object[18]"]]:::plan
    PgClassExpression34{{"PgClassExpression[34∈3]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression34 --> PgSelect35
    PgClassExpression22{{"PgClassExpression[22∈3]<br />ᐸ__messages__.”id”ᐳ"}}:::plan
    PgSelectSingle21 --> PgClassExpression22
    PgClassExpression23{{"PgClassExpression[23∈3]<br />ᐸ__messages__.”featured”ᐳ"}}:::plan
    PgClassExpression22 o--o PgClassExpression23
    PgClassExpression24{{"PgClassExpression[24∈3]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgClassExpression23 o--o PgClassExpression24
    PgClassExpression25{{"PgClassExpression[25∈3]<br />ᐸ(__message... not null)ᐳ"}}:::plan
    PgClassExpression24 o--o PgClassExpression25
    PgSelectSingle21 --> PgClassExpression26
    First31{{"First[31∈3]"}}:::plan
    PgSelectRows32[["PgSelectRows[32∈3]"]]:::plan
    PgSelectRows32 --> First31
    PgSelect27 --> PgSelectRows32
    PgSelectSingle33{{"PgSelectSingle[33∈3]<br />ᐸforumsᐳ"}}:::plan
    First31 --> PgSelectSingle33
    PgSelectSingle21 --> PgClassExpression34
    First37{{"First[37∈3]"}}:::plan
    PgSelectRows38[["PgSelectRows[38∈3]"]]:::plan
    PgSelectRows38 --> First37
    PgSelect35 --> PgSelectRows38
    PgSelectSingle39{{"PgSelectSingle[39∈3]<br />ᐸusersᐳ"}}:::plan
    First37 --> PgSelectSingle39
    PgClassExpression42{{"PgClassExpression[42∈4]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle33 --> PgClassExpression42
    PgClassExpression44{{"PgClassExpression[44∈4]<br />ᐸ(__forums_... not null)ᐳ"}}:::plan
    PgClassExpression42 o--o PgClassExpression44
    PgClassExpression41{{"PgClassExpression[41∈5]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle39 --> PgClassExpression41
    PgClassExpression43{{"PgClassExpression[43∈5]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression41 o--o PgClassExpression43

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,Lambda7,Access8,Listen9,Access16,Access17,Object18 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item10,JSONParse11 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,Access12,Lambda13,Access14,PgSelect15,First19,PgSelectRows20,PgSelectSingle21 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,PgClassExpression22,PgClassExpression23,PgClassExpression24,PgClassExpression25,PgClassExpression26,PgSelect27,First31,PgSelectRows32,PgSelectSingle33,PgClassExpression34,PgSelect35,First37,PgSelectRows38,PgSelectSingle39 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression42,PgClassExpression44 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression41,PgClassExpression43 bucket5

